
// 根据登录
var isLogin = $.cookie("isLogin");
var account = document.getElementById("account");
var host = location.origin;
if (isLogin != "1") {
    let str = `
        <li><a href="${host}/html/login.html">登录</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">我的账号</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="${host}/html/regist.html">注册</a></li>
    `;
    account.firstChild.innerHTML = `我的账号 <span class="caret"></span>`;

    var login = document.createElement("ul");
    login.className = "dropdown-menu";
    login.innerHTML = str;
    account.appendChild(login);
    
} else if (isLogin == "1") {
    var $nickname = $.cookie('nickname');
    var $id = $.cookie('id');
    var $username = $.cookie('username');
    console.log($nickname, $id);
    // ?????????????? nt 用origin
    let str = `
        <li class="user">
        <p class="nickname"><span>${$nickname}</span>#<span>${$id}</span></p>
        <p class="username">${$username}</p>
        </li>
        <li role="separator" class="divider"></li>
        <li><a href="#">账户</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="${host}/html/cart.html" target = "_blank">购物车</a></li>
        <li role="separator" class="divider"></li>
        <li><button id="logout">注销</button></li>
    `;
    account.firstChild.innerHTML = $nickname + ` <span class="caret"></span>`;
    var login = document.createElement("ul");
    login.className = "dropdown-menu";
    login.innerHTML = str;
    account.appendChild(login);
}


